<?php

use yii\helpers\Html;
use metronic\grid\GridView;

/* @var $model common\models\Category */
?>

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],

        [
            'attribute' => 'image',
            'format' => 'image',
            'value' => function($model) {
                return $model->image->resize(200, 70);
            }
        ],

        [
            'label' => '关联书籍',
            'value' => function($model) {
                return $model->book->name;
            }
        ],

        'des',

        'display_order',

        [
            'class' => 'metronic\grid\ActionColumn',
            'template' => '{update} {delete} {up}',
            'buttons' => [
                'view' => function ($url, $model) {
                    return Html::actionButton('查看', ['category-book/index', 'id' => $model->id], 'eye', 'blue', ['title' => '查看该推荐位的作品列表']);
                },
                'delete' => function ($url, $model) {
                    $options = ['data-confirm' => '您确定要删除该推荐位吗？', 'data-method' => 'delete'];
                    return Html::actionButton('删除', $url, 'trash-o', 'dark', $options);
                },
                'up' => function($url, $model) {
                    return Html::a('<i class="fa fa-arrow-up">置顶</i>', ['/banner/up', 'id' => $model->id], ['class' => 'btn btn-outline btn-circle btn-xs blue']);
                }
            ],
        ],

    ],
]); ?>
